package com.soup.lab.spring.web.controller;

import com.soup.lab.spring.web.pojo.NestedPojo;
import com.soup.lab.spring.web.pojo.OtherPojo;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

@RestController
public class JsonSerializerTestController {

    @RequestMapping("/a")
    public OtherPojo a() {
        return new OtherPojo("1", 1);
    }

    @RequestMapping("/b")
    public OtherPojo b() {
        return new OtherPojo("-1", null);
    }

    @RequestMapping("/d")
    public OtherPojo d() {
        return new OtherPojo("0", null);
    }

    @RequestMapping("/n")
    public NestedPojo n() {
        return new NestedPojo(Arrays.asList(new OtherPojo("0", null)));
    }

    @RequestMapping("/nil")
    public NestedPojo nil() {
        return new NestedPojo(null);
    }

    @RequestMapping("/nil1")
    public NestedPojo[] nil1() {
        return null;
    }

    @RequestMapping("/nil2")
    public List<NestedPojo> nil2() {
        return Collections.emptyList();
    }

}
